package com.telit.dispose.feign;

import com.telit.common.dto.SysUserRolePageDto;
import com.telit.common.entity.SysRole;
import com.telit.common.vo.user.Result;
import com.telit.common.vo.user.SysUserInfoVo;
import com.telit.common.vo.user.SysUserPageDto;
import com.telit.common.vo.user.SysUserShortVo;
import com.telit.dispose.feign.impl.UpmsFeignClientFallBack;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @Auther amy
 * @Describe 统一平台feign调用
 */
@FeignClient(name = "pt-upms", fallback = UpmsFeignClientFallBack.class)
public interface UpmsFeignClient {

    /**
     * 单个用户信息
     *
     * @param id
     *
     * @return
     */
    @GetMapping(value = {"/feign/user/{id}"})
    Result getUserDetail(@PathVariable(value = "id", required = false) Long id);

    @ApiOperation(value = "依据角色及组合条件查询全部用户列表结果")
    @GetMapping("/user/getListForRole")
    Result<List<SysUserShortVo>> getListForRole(@SpringQueryMap SysUserRolePageDto sysUserRolePageDto);

    @GetMapping("/user/getCountForRole")
    @ApiOperation(value = "依据角色及组合条件查询用户数")
    Result<Long> getCountForRole(@SpringQueryMap SysUserRolePageDto sysUserRolePageDto);

    /**
     * 查询用户详情
     *
     * @param ids
     *
     * @return
     */
    @ApiOperation(value = "依据多个用户id查询用户所属单位、部门等主要信息列表")
    @GetMapping("/user/queryUserListByIds/{ids}")
    Result<List<SysUserShortVo>> queryUserListByIds(@PathVariable("ids") List<Long> ids);


    @GetMapping("/user/queryUserInfoByIds/{ids}")
    Result<List<SysUserInfoVo>> queryUserInfoByIds(@PathVariable("ids") List<Long> ids);

    @ApiOperation(value = "依据角色及行政区划查询行政区划及以上的用户列表")
    @GetMapping("/user/getListForRoleAndDistrictCode")
    Result<List<SysUserShortVo>> getListForRoleAndDistrictCode(@SpringQueryMap SysUserRolePageDto sysUserRolePageDto);

    @ApiOperation("根据用户ID查询角色信息")
    @RequestMapping(value = "/user/queryRoleByUserId", method = RequestMethod.GET)
    Result<List<SysRole>> queryRoleByUserId(@RequestParam(value = "userId") Long userId);

    @ApiOperation("依据上级行政区划编码查询下级行政区划列表")
    @RequestMapping(value = "/district/list/{code}", method = RequestMethod.GET)
    Result queryDistrictList(@PathVariable(value = "code") String code);

    @ApiOperation("依据行政区划编码查询所属行政区划信息")
    @RequestMapping(value = "/district/{code}", method = RequestMethod.GET)
    Result queryDistrictTree(@PathVariable(value = "code") String code);

    /**
     * 查询当前用户管辖范围的行政区划树(控层级、数量过多)
     *
     * @return Result Obj
     */
    @GetMapping(value = "/district/tree", produces = MediaType.APPLICATION_JSON_VALUE)
    Result qryDistrictTree();

    /**
     * 根据父类code获取所有子行政区树
     *
     * @param district 父类code
     *
     * @return Result Obj
     */
    @GetMapping(value = "/district/districtTree/{district}", produces = MediaType.APPLICATION_JSON_VALUE)
    Result qryAllByParentCode(@PathVariable(value = "district") String district);

    /**
     * 依据组合条件查询全部用户列表结果
     *
     * @param sysUserPageDto SysUserPageDto
     *
     * @return 全部用户列表
     */
    @GetMapping("/user/getListForCustomer")
    Result<List<SysUserShortVo>> getListForCustomer(@SpringQueryMap SysUserPageDto sysUserPageDto);


    /**
     * 根据用户ID 获取用户经纬度
     */
    @ApiOperation("根据用户ID查询角色信息")
    @RequestMapping(value = "/feign/user/getUserLocation", method = RequestMethod.GET)
    Result getUserLocation(@RequestParam(value = "userId") Long userId);

}
